﻿var sellist = '[{"id": "1","text": "广东省","helpcode":"gds","list": [{"id": "1","text": "广州市","helpcode":"gzs"},{"id": 2,"text": "深圳市","helpcode":"szs"},{"id": 3,"text": "珠海市","helpcode":"zhs"}]}'
    + ',{"id": 2,"text": "广西省","helpcode":"gxs","list": [{"id": 4,"text": "南宁市","helpcode":"nns"},{"id": 5,"text": "柳州市","helpcode":"lzs"},{"id": 6, "text": "桂林市","helpcode":"gls"}]}'
    + ',{"id": 3,"text": "山东省","helpcode":"sds", "list": [{"id": 7, "text": "烟台市","helpcode":"yts"}, {"id": 8, "text": "青岛市","helpcode":"qds"},{"id": 9, "text": "济南市","helpcode":"jns"}]}]';
 
var sellist1 = '[{"id": "1","text": "饮料","helpcode":"yl","list": [{"id": "1","text": "可口可乐","helpcode":"kkkl"},{"id": 2,"text": "百事可乐","helpcode":"bskl"},{"id": 3,"text": "雪碧","helpcode":"xb"}]}'
    + ',{"id": 2,"text": "槟榔","helpcode":"bl","list": [{"id": 4,"text": "张新发10元","helpcode":"zxf10y"},{"id": 5,"text": "九总10元","helpcode":"jz10y"},{"id": 6, "text": "胖哥10元","helpcode":"pg10y"}]}'
    + ',{"id": 3,"text": "麻辣熟食","helpcode":"mlss", "list": [{"id": 7, "text": "川幺妹牛肉麻辣味","helpcode":"cymnrmlw"}, {"id": 8, "text": "川味鱼村沙丁鱼","helpcode":"cwycsdy"},{"id": 9, "text": "老农夫辣子鸡","helpcode":"llflzj"}]}]';


//bootstrap-select api URL:https://blog.csdn.net/Bern_Liu/article/details/81660631
//console.log($(this).val());
        //var _this = $(this);
        //var parentlist = [];
        //var sonlist = [];
        //var selectedOption = $(this).find("option:selected");

        //if (selectedOption.length > 0) {
        //    if (selectedOption[0].label == "parent") {
        //        parentlist.push(selectedOption[0].value.toString().replace('p_', ''));
        //        //sonlist.push(selectedOption[0].value);
        //        var sonOption = selectedOption.siblings();
        //        sonOption.each(function () {
        //            sonlist.push($(this)[0].value);
        //            $(this)[0].selected = true;
        //        });
        //        //$(this).selectpicker('val', sonlist);

        //    }
        //}
        //$(this).selectpicker('refresh');
        ////var optionlist = $(this).find("option:selected").siblings();
        ////var optlist = [];
        ////optionlist.each(function (){
        ////    optlist.push($(this)[0].value); 
        ////}); 
        ////$(this).selectpicker('val', optlist);

//(function ($) {
//    $.fn.change = function () {
//    };
//    $.fn.shown = function () {
//        var _this = $(this);
//        shownlist = _this.val();
//    };
//})(jQuery);
 
//var seldefault = function (item) {
//    $(item).selectpicker({
//        'noneSelectedText': '请选择',
//        'deselectAllText': '全不选',
//        'selectAllText': '全选'
//    });
//};

//var selchange = function (item) { 
//    var _this = $(item);
//    var vallist = _this.val();
//    var parentOptionList = $(item).find('option[label="parent"]')
//    parentOptionList.each(function () { 
//        var tmp = true;
//        if ($(this)[0].selected == true) { 
//            var _val = $(this)[0].value;
//            var nextallOptionList = $(this).nextAll();
//            nextallOptionList.each(function () { 
//                if ($(this)[0].selected == false) { 
//                    tmp == false;
//                    return false;
//                } 
//            }); 
//            $(this)[0].selected = tmp;
//            console.log(vallist);
//            vallist.splice($.inArray(_val, vallist), 1);
//            console.log(vallist);
//            _this.selectpicker('val', vallist);
//        }
//    });
//    _this.selectpicker('refresh')
//}; 
//var selchanged = function (item) {
//    elist = $(item).val(); 

//}